package day10;

import java.util.Arrays;
import java.util.Random;
import java.util.Scanner;

public class A3 {
    public static void main(String[] args) {
        Random r = new Random();
        int x = r.nextInt(1000);
        String s = Integer.toString(x);
        //System.out.println(s);
        if(s.length()==1){
            s="00"+s;
        }
        else if(s.length()==2){
            s="0"+s;
        }
        System.out.println(s);
    }
}

class B3{
    public static void main(String[] args) {
        String[] str = {"nba", "abc", "cba", "aaaa", "z", "qq"};
        for (int i = 0; i < str.length - 1; i++) {
            for (int j = 0; j < str.length - 1 - i; j++) {
                if (str[j].compareTo(str[j + 1]) > 0) {
                    String temp = str[j];
                    str[j] = str[j + 1];
                    str[j + 1] = temp;
                }
            }
        }
        System.out.println(Arrays.toString(str));
    }
}

class A4{
    public static void main(String[] args) {
        Random r = new Random();
        char[] s = {'<','>','#','@','$','%','&'};
        for (int i = 1; i <= 6; i++) {
            System.out.print("第"+i+"级的随机字符串:");
            for (int j = 0; j < i+1; j++) {
                int n = r.nextInt(i+1);
                System.out.print(s[n]);
            }
            System.out.println(" ");
        }
    }
}

class B4{
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        System.out.println("请输入主字符串:");
        String str = sc.next();
        System.out.print("请输入子字符串:");
        String str1 = sc.next();
        int count = 0;
        for (int i = 0; i <= str.length()-str1.length(); ) {
            if (str1.equals(str.substring(i, i + str1.length()))) {
                count++;
                i=i+str1.length();
            }
            else {
                i++;
            }
        }
        System.out.println("出现次数:"+count);
    }
}